using System;
using System.Collections.Generic;
using System.Text;

namespace Sandia.MVCFramework.Data
{
    /// <summary>
    /// Encapsulates data for transmission from
    /// elements of the model (DataAccessors,
    /// DataAnalyzers) to the Controller to 
    /// elements of the view (ViewManagers, Views)
    /// </summary>
    public class DataPacket
    {
        /// <summary>
        /// The data held in the data packet
        /// </summary>
        IData data;

        /// <summary>
        /// Unique id for the data packet
        /// </summary>
        string packetID;

        string requesterID;

        /// <summary>
        /// Default constructor; encapsulates
        /// provided data and assigns unique id
        /// to the data packet
        /// </summary>
        /// <param name="data">Data to be
        /// encapsulated</param>
        /// <param name="requesterID">Identifier of the requester</param>
        public DataPacket(
            IData data,
            string requesterID)
        {
            this.data = data;
            this.requesterID = requesterID;
            this.packetID = System.Guid.NewGuid().ToString();
        }

        /// <summary>
        /// The data held in the data packet
        /// </summary>
        public IData Data
        {
            get { return this.data; }
            set { this.data = value; }
        }

        /// <summary>
        /// The unique id for the data packet
        /// </summary>
        public string PacketID
        {
            get { return this.packetID; }
            set { this.packetID = value; }
        }

        /// <summary>
        /// The type of the data held in the data packet
        /// </summary>
        public Type DataType
        {
            get { return this.data.GetType(); }
        }

        /// <summary>
        /// Identifier for the requester
        /// </summary>
        public string RequesterID
        {
            get { return this.requesterID; }
            set { this.requesterID = value; }
        }
    }
}
